//
//  CustomViewController.m
//  MyShiDiQuan
//
//  Created by cvicseks-mac1 on 16/9/6.
//  Copyright © 2016年 cvicseks-mac1. All rights reserved.
//

#import "CustomTabBarViewController.h"

@interface CustomTabBarViewController ()

@end

@implementation CustomTabBarViewController

+ (instancetype)shareInstance{
    static dispatch_once_t once;
    static id intance;
    dispatch_once(&once, ^{
        intance = [self new];
    });
    return intance;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)setUpChildViewController:(UIViewController*)viewController WithTitle:(NSString*)title titleAttributes:(NSDictionary *)attributes andState:(UIControlState)state imageName:(NSString*)imageName seletedImageName:(NSString*)seletedImageName
{
    UITabBarItem *tabbarItem = viewController.tabBarItem;
    tabbarItem.title = title;
    tabbarItem.image = [UIImage imageNamed:imageName];
    tabbarItem.selectedImage = [[UIImage imageNamed:seletedImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    if (attributes&&state) {
        [tabbarItem setTitleTextAttributes:attributes forState:state];
    }
    
    viewController.title = title;
    [self addChildViewController:[[UINavigationController alloc] initWithRootViewController:viewController]];
}
- (void)setUpChildViewController:(UIViewController*)viewController WithTitle:(NSString*)title titleAttributes:(NSDictionary *)attributes andState:(UIControlState)state selectTitleAttributes:(NSDictionary *)selectattributes andSelectState:(UIControlState)selectstate imageName:(NSString*)imageName seletedImageName:(NSString*)seletedImageName
{
    UITabBarItem *tabbarItem = viewController.tabBarItem;
    tabbarItem.title = title;
    tabbarItem.image = [UIImage imageNamed:imageName];
    tabbarItem.selectedImage = [[UIImage imageNamed:seletedImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    if (attributes&&state) {
        [tabbarItem setTitleTextAttributes:attributes forState:state];
    }
    if (selectattributes&&selectstate) {
        [tabbarItem setTitleTextAttributes:selectattributes forState:selectstate];
    }
    
//    viewController.title = title;
    [self addChildViewController:[[UINavigationController alloc] initWithRootViewController:viewController]];
}

- (void)setUpChildViewControllerNoNavi:(UIViewController*)viewController WithTitle:(NSString*)title imageName:(NSString*)imageName seletedImageName:(NSString*)seletedImageName
{
    UITabBarItem *tabbarItem = viewController.tabBarItem;
    tabbarItem.title = title;
    tabbarItem.image = [UIImage imageNamed:imageName];
    tabbarItem.selectedImage = [[UIImage imageNamed:seletedImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [tabbarItem setTitleTextAttributes:@{
                                         NSForegroundColorAttributeName:[UIColor grayColor],
                                         NSFontAttributeName:[UIFont systemFontOfSize:11]
                                         } forState:UIControlStateNormal];
    [tabbarItem setTitleTextAttributes:@{
                                         NSForegroundColorAttributeName:[UIColor redColor],
                                         NSFontAttributeName:[UIFont systemFontOfSize:11]
                                         } forState:UIControlStateSelected];
    
    viewController.title = title;
    [self addChildViewController:viewController];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
